<!DOCTYPE html><html><head><meta charset=utf-8><title>H3DU.Polyhedra</title></head><body><h1> H3DU.Polyhedra</h1><p><a href='index.html'>Back to documentation index.</a></p><a name='H3DU.Polyhedra'></a>
<h3> H3DU.Polyhedra()</h3>Contains helper methods for generating the five platonic solids
and other polyhedra.<p>
To use this class, you must include the script "extras/polyhedra.js"; the
class is not included in the "h3du_min.js" file which makes up
the HTML 3D Library. Example:<pre>
&lt;script type="text/javascript" src="extras/polyhedra.js">&lt;/script></pre><h3> Methods</h3><ul><li><a href='#H3DU.Polyhedra.dodecahedron'>dodecahedron</a><br>Generates a mesh of a regular dodecahedron or a sphere based on that solid.<li><a href='#H3DU.Polyhedra.dodecahedronFaces'>dodecahedronFaces</a><br>Gets the vertices of a dodecahedron with maximum radius 1.<li><a href='#H3DU.Polyhedra.dodecahedronFacesCompact'>dodecahedronFacesCompact</a><br>Gets a more compact representation of the vertices of a dodecahedron
with maximum radius 1.<li><a href='#H3DU.Polyhedra.hexahedron'>hexahedron</a><br>Generates a mesh of a regular hexahedron (cube) or a sphere based on that solid.<li><a href='#H3DU.Polyhedra.hexahedronFaces'>hexahedronFaces</a><br>Gets the vertices of a hexahedron (cube) with maximum radius 1.<li><a href='#H3DU.Polyhedra.hexahedronFacesCompact'>hexahedronFacesCompact</a><br>Gets a more compact representation of the vertices of a hexahedron
(cube) with maximum radius 1.<li><a href='#H3DU.Polyhedra.icosahedron'>icosahedron</a><br>Generates a mesh of a regular icosahedron or a sphere based on that solid.<li><a href='#H3DU.Polyhedra.icosahedronFaces'>icosahedronFaces</a><br>Gets the vertices of a regular icosahedron with maximum radius 1.<li><a href='#H3DU.Polyhedra.makeSphere'>makeSphere</a><br>Modifies the vertices and indices of a solid to
generate an approximation of a sphere.<li><a href='#H3DU.Polyhedra.normDistances'>normDistances</a><br>Normalizes the distance from the origin to each vertex in the given
array to a fixed radius.<li><a href='#H3DU.Polyhedra.octahedron'>octahedron</a><br>Generates a mesh of a regular octahedron or a sphere based on that solid.<li><a href='#H3DU.Polyhedra.octahedronFaces'>octahedronFaces</a><br>Gets the vertices of a regular octahedron with radius 1.<li><a href='#H3DU.Polyhedra.tetrahedron'>tetrahedron</a><br>Generates a mesh of a regular tetrahedron or a sphere based on that solid.<li><a href='#H3DU.Polyhedra.tetrahedronFaces'>tetrahedronFaces</a><br>Gets the vertices of a tetrahedron with radius 1.</ul><a name='H3DU.Polyhedra.dodecahedron'></a>
<h3> (static) H3DU.Polyhedra.dodecahedron(radius, level)</h3>Generates a mesh of a regular dodecahedron or a sphere based on that solid.<h4> Parameters</h4><ul><li><code>radius</code> (Type: number)<br>Maximum radius from the center of the solid to one of its vertices.<li><code>level</code> (Type: number)<br>If 0 or less, generates the solid as is. If 1 or greater, subdivides each triangle on the solid's surface into smaller triangles and makes them bulge out to form an approximation of a sphere (the bigger the number, the smaller the triangles).</ul><h4> Return Value</h4>The generated solid. (Type: <a href="H3DU.MeshBuffer.html">H3DU.MeshBuffer</a>)<a name='H3DU.Polyhedra.dodecahedronFaces'></a>
<h3> (static) H3DU.Polyhedra.dodecahedronFaces()</h3>Gets the vertices of a dodecahedron with maximum radius 1.<h4> Return Value</h4>A two-element array. The first
element contains an array of the vertices that make up the solid (each
vertex's X, Y, and Z coordinates are stored as three elements of that array),
and the second element contains an array of vertex indices (multiplying
each element by 3 will get the index to the first coordinate of the corresponding
vertex in the first array). (Type: Array.&lt;Array.&lt;number>>)<a name='H3DU.Polyhedra.dodecahedronFacesCompact'></a>
<h3> (static) H3DU.Polyhedra.dodecahedronFacesCompact()</h3>Gets a more compact representation of the vertices of a dodecahedron
with maximum radius 1.<h4> Return Value</h4>A two-element array. The first
element contains an array of the vertices that make up the solid (each
vertex's X, Y, and Z coordinates are stored as three elements of that array),
and the second element contains an array of vertex indices (multiplying
each element by 3 will get the index to the first coordinate of the corresponding
vertex in the first array). (Type: Array.&lt;Array.&lt;number>>)<a name='H3DU.Polyhedra.hexahedron'></a>
<h3> (static) H3DU.Polyhedra.hexahedron(radius, level)</h3>Generates a mesh of a regular hexahedron (cube) or a sphere based on that solid.<h4> Parameters</h4><ul><li><code>radius</code> (Type: number)<br>Maximum radius from the center of the solid to one of its vertices.<li><code>level</code> (Type: number)<br>If 0 or less, generates the solid as is. If 1 or greater, subdivides each triangle on the solid's surface into smaller triangles and makes them bulge out to form an approximation of a sphere (the bigger the number, the smaller the triangles).</ul><h4> Return Value</h4>The generated solid. (Type: <a href="H3DU.MeshBuffer.html">H3DU.MeshBuffer</a>)<a name='H3DU.Polyhedra.hexahedronFaces'></a>
<h3> (static) H3DU.Polyhedra.hexahedronFaces()</h3>Gets the vertices of a hexahedron (cube) with maximum radius 1.<h4> Return Value</h4>A two-element array. The first
element contains an array of the vertices that make up the solid (each
vertex's X, Y, and Z coordinates are stored as three elements of that array),
and the second element contains an array of vertex indices (multiplying
each element by 3 will get the index to the first coordinate of the corresponding
vertex in the first array). (Type: Array.&lt;Array.&lt;number>>)<a name='H3DU.Polyhedra.hexahedronFacesCompact'></a>
<h3> (static) H3DU.Polyhedra.hexahedronFacesCompact()</h3>Gets a more compact representation of the vertices of a hexahedron
(cube) with maximum radius 1.<h4> Return Value</h4>A two-element array. The first
element contains an array of the vertices that make up the solid (each
vertex's X, Y, and Z coordinates are stored as three elements of that array),
and the second element contains an array of vertex indices (multiplying
each element by 3 will get the index to the first coordinate of the corresponding
vertex in the first array). (Type: Array.&lt;Array.&lt;number>>)<a name='H3DU.Polyhedra.icosahedron'></a>
<h3> (static) H3DU.Polyhedra.icosahedron(radius, level)</h3>Generates a mesh of a regular icosahedron or a sphere based on that solid.<h4> Parameters</h4><ul><li><code>radius</code> (Type: number)<br>Maximum radius from the center of the solid to one of its vertices.<li><code>level</code> (Type: number)<br>If 0 or less, generates the solid as is. If 1 or greater, subdivides each triangle on the solid's surface into smaller triangles and makes them bulge out to form an approximation of a sphere (the bigger the number, the smaller the triangles).</ul><h4> Return Value</h4>The generated solid. (Type: <a href="H3DU.MeshBuffer.html">H3DU.MeshBuffer</a>)<a name='H3DU.Polyhedra.icosahedronFaces'></a>
<h3> (static) H3DU.Polyhedra.icosahedronFaces()</h3>Gets the vertices of a regular icosahedron with maximum radius 1.<h4> Return Value</h4>A two-element array. The first
element contains an array of the vertices that make up the solid (each
vertex's X, Y, and Z coordinates are stored as three elements of that array),
and the second element contains an array of vertex indices (multiplying
each element by 3 will get the index to the first coordinate of the corresponding
vertex in the first array). (Type: Array.&lt;Array.&lt;number>>)<a name='H3DU.Polyhedra.makeSphere'></a>
<h3> (static) H3DU.Polyhedra.makeSphere(vi, radius, level)</h3>Modifies the vertices and indices of a solid to
generate an approximation of a sphere.<h4> Parameters</h4><ul><li><code>vi</code> (Type: Array.&lt;Array.&lt;number>>)<br>A two-element array. The first element contains an array of the vertices that make up the solid (each vertex's X, Y, and Z coordinates are stored as three elements of that array), and the second element contains an array of vertex indices (multiplying each element by 3 will get the index to the first coordinate of the corresponding vertex in the first array).<li><code>radius</code> (Type: number)<br>Maximum radius from the center of the solid to one of its vertices.<li><code>level</code> (Type: number)<br>If 0 or less, generates the solid as is. If 1 or greater, subdivides each triangle on the solid's surface into smaller triangles and makes them bulge out to form an approximation of a sphere (the bigger the number, the smaller the triangles).</ul><h4> Return Value</h4>The "vi" parameter, which will likely be modified. (Type: Array.&lt;Array.&lt;number>>)<a name='H3DU.Polyhedra.normDistances'></a>
<h3> (static) H3DU.Polyhedra.normDistances(vertices, radius)</h3>Normalizes the distance from the origin to each vertex in the given
array to a fixed radius.<h4> Parameters</h4><ul><li><code>vertices</code> (Type: Array.&lt;number>)<br>An array of vertices, where each vertex's X, Y, and Z coordinates are stored as three elements of that array.<li><code>radius</code> (Type: number)<br>Distance from the origin where each vertex will be normalized to.</ul><h4> Return Value</h4>Return value. (Type: Object)<a name='H3DU.Polyhedra.octahedron'></a>
<h3> (static) H3DU.Polyhedra.octahedron(radius, level)</h3>Generates a mesh of a regular octahedron or a sphere based on that solid.<h4> Parameters</h4><ul><li><code>radius</code> (Type: number)<br>Maximum radius from the center of the solid to one of its vertices.<li><code>level</code> (Type: number)<br>If 0 or less, generates the solid as is. If 1 or greater, subdivides each triangle on the solid's surface into smaller triangles and makes them bulge out to form an approximation of a sphere (the bigger the number, the smaller the triangles).</ul><h4> Return Value</h4>The generated solid. (Type: <a href="H3DU.MeshBuffer.html">H3DU.MeshBuffer</a>)<a name='H3DU.Polyhedra.octahedronFaces'></a>
<h3> (static) H3DU.Polyhedra.octahedronFaces()</h3>Gets the vertices of a regular octahedron with radius 1.<h4> Return Value</h4>A two-element array. The first
element contains an array of the vertices that make up the solid (each
vertex's X, Y, and Z coordinates are stored as three elements of that array),
and the second element contains an array of vertex indices (multiplying
each element by 3 will get the index to the first coordinate of the corresponding
vertex in the first array). (Type: Array.&lt;Array.&lt;number>>)<a name='H3DU.Polyhedra.tetrahedron'></a>
<h3> (static) H3DU.Polyhedra.tetrahedron(radius, level)</h3>Generates a mesh of a regular tetrahedron or a sphere based on that solid.<h4> Parameters</h4><ul><li><code>radius</code> (Type: number)<br>Maximum radius from the center of the solid to one of its vertices.<li><code>level</code> (Type: number)<br>If 0 or less, generates the solid as is. If 1 or greater, subdivides each triangle on the solid's surface into smaller triangles and makes them bulge out to form an approximation of a sphere (the bigger the number, the smaller the triangles).</ul><h4> Return Value</h4>The generated solid. (Type: <a href="H3DU.MeshBuffer.html">H3DU.MeshBuffer</a>)<a name='H3DU.Polyhedra.tetrahedronFaces'></a>
<h3> (static) H3DU.Polyhedra.tetrahedronFaces()</h3>Gets the vertices of a tetrahedron with radius 1.<h4> Return Value</h4>A two-element array. The first
element contains an array of the vertices that make up the solid (each
vertex's X, Y, and Z coordinates are stored as three elements of that array),
and the second element contains an array of vertex indices (multiplying
each element by 3 will get the index to the first coordinate of the corresponding
vertex in the first array). (Type: Array.&lt;Array.&lt;number>>)<p><a href='index.html'>Back to documentation index.</a></p></body></html>
